libxc: Clarify xc_mmu interface and make it private.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 6 Apr 2007 21:48:25 +0000 (22:48 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 6 Apr 2007 21:48:25 +0000 (22:48 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/libxc/xc_domain_restore.c
tools/libxc/xc_private.c
tools/libxc/xc_private.h
tools/libxc/xenctrl.h

index 624c675b9eaca1eb42b1dc9dc79c287026342a6c..e1bc0c02c213ae4278e0aba9bdf29f15c928499b 100644 (file)
@@ -284,7 +284,7 @@ int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,
     /* Our mapping of the current region (batch) */
     char *region_base;
 
-    xc_mmu_t *mmu = NULL;
+    struct xc_mmu *mmu = NULL;
 
     /* used by debug verify code */
     unsigned long buf[PAGE_SIZE/sizeof(unsigned long)];
@@ -386,7 +386,9 @@ int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,
     for ( pfn = 0; pfn < p2m_size; pfn++ )
         p2m[pfn] = INVALID_P2M_ENTRY;
 
-    if(!(mmu = xc_init_mmu_updates(xc_handle, dom))) {
+    mmu = xc_alloc_mmu_updates(xc_handle, dom);
+    if ( mmu == NULL )
+    {
         ERROR("Could not initialise for MMU updates");
         goto out;
     }
@@ -629,8 +631,8 @@ int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,
      * Ensure we flush all machphys updates before potential PAE-specific
      * reallocations below.
      */
-    if (!hvm && xc_finish_mmu_updates(xc_handle, mmu)) {
-        ERROR("Error doing finish_mmu_updates()");
+    if (!hvm && xc_flush_mmu_updates(xc_handle, mmu)) {
+        ERROR("Error doing flush_mmu_updates()");
         goto out;
     }
 
@@ -810,8 +812,8 @@ int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,
             }
         }
 
-        if (xc_finish_mmu_updates(xc_handle, mmu)) {
-            ERROR("Error doing finish_mmu_updates()");
+        if (xc_flush_mmu_updates(xc_handle, mmu)) {
+            ERROR("Error doing xc_flush_mmu_updates()");
             goto out;
         }
     }
index 3e2557e581b827ea3b419247654c8768772698cd..9ac035f8af9d62b719e3b0925ce9e5b81ad219ee 100644 (file)
@@ -145,7 +145,7 @@ int xc_mmuext_op(
     return ret;
 }
 
-static int flush_mmu_updates(int xc_handle, xc_mmu_t *mmu)
+static int flush_mmu_updates(int xc_handle, struct xc_mmu *mmu)
 {
     int err = 0;
     DECLARE_HYPERCALL;
@@ -180,9 +180,9 @@ static int flush_mmu_updates(int xc_handle, xc_mmu_t *mmu)
     return err;
 }
 
-xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom)
+struct xc_mmu *xc_alloc_mmu_updates(int xc_handle, domid_t dom)
 {
-    xc_mmu_t *mmu = malloc(sizeof(xc_mmu_t));
+    struct xc_mmu *mmu = malloc(sizeof(*mmu));
     if ( mmu == NULL )
         return mmu;
     mmu->idx     = 0;
@@ -190,7 +190,7 @@ xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom)
     return mmu;
 }
 
-int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
+int xc_add_mmu_update(int xc_handle, struct xc_mmu *mmu,
                       unsigned long long ptr, unsigned long long val)
 {
     mmu->updates[mmu->idx].ptr = ptr;
@@ -202,7 +202,7 @@ int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
     return 0;
 }
 
-int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu)
+int xc_flush_mmu_updates(int xc_handle, struct xc_mmu *mmu)
 {
     return flush_mmu_updates(xc_handle, mmu);
 }
index 7fa3258db11609b0ce8d36b1ad5e99dd953aef68..09e1bdf4ad4218d3d1f0b1010e22573ebb26d880 100644 (file)
@@ -168,4 +168,16 @@ void bitmap_byte_to_64(uint64_t *lp, const uint8_t *bp, int nbits);
 /* Optionally flush file to disk and discard page cache */
 void discard_file_cache(int fd, int flush);
 
+#define MAX_MMU_UPDATES 1024
+struct xc_mmu {
+    mmu_update_t updates[MAX_MMU_UPDATES];
+    int          idx;
+    domid_t      subject;
+};
+/* Structure returned by xc_alloc_mmu_updates must be free()'ed by caller. */
+struct xc_mmu *xc_alloc_mmu_updates(int xc_handle, domid_t dom);
+int xc_add_mmu_update(int xc_handle, struct xc_mmu *mmu,
+                   unsigned long long ptr, unsigned long long val);
+int xc_flush_mmu_updates(int xc_handle, struct xc_mmu *mmu);
+
 #endif /* __XC_PRIVATE_H__ */
index 22894d10060df729a7b37a8874ee645cc90dc689..1073b8bcb5de6596387ec0fd891bfac71575a159 100644 (file)
@@ -666,21 +666,6 @@ int xc_sysctl(int xc_handle, struct xen_sysctl *sysctl);
 
 int xc_version(int xc_handle, int cmd, void *arg);
 
-/*
- * MMU updates.
- */
-#define MAX_MMU_UPDATES 1024
-struct xc_mmu {
-    mmu_update_t updates[MAX_MMU_UPDATES];
-    int          idx;
-    domid_t      subject;
-};
-typedef struct xc_mmu xc_mmu_t;
-xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom);
-int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu,
-                   unsigned long long ptr, unsigned long long val);
-int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu);
-
 int xc_acm_op(int xc_handle, int cmd, void *arg, unsigned long arg_size);
 
 /*